'use strict'

const Service = require('egg').Service

class VisitService extends Service {
  // 添加访问记录
  async createVisit() {
    const { app } = this
    const visit = await app.model.Visit.findOne()
    if (!visit) {
      app.model.Visit.create({ count: 1 })
    } else {
      visit.update({ count: visit.count + 1 })
    }
  }
}

module.exports = VisitService
